package com.atguigu.algorithm;

import java.util.ArrayList;

public class Permute {
    public static void process(char[] str, int i, ArrayList<String> res){
        if(i==str.length){
            res.add(String.valueOf(str));
        }
        boolean[] visit=new boolean[26];
        for(int j=i;j<str.length;j++){
            if(!visit[str[j]-'a']){
                visit[str[j]-'a']=true;
                    swap(str,i,j);
                    process(str,i+1,res);
                    swap(str,i,j);
            }
        }
    }
    public static void swap(char[] ch,int i,int j){
        char tmp=ch[i];
        ch[i]=ch[j];
        ch[j]=tmp;
    }
}
